var app = getApp(),
  api = getApp().api;

Page({

  /**
   * 页面的初始数据
   */
  data: {
    dqwz: "定位中...",
    city: '',
    hotcityList: [],
    cityList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {
    var t = this;
    getApp().page.onLoad(this, e), t.getLocation();
  },

  getLocation: function () {
    var n = this;
    wx.getLocation({
      type: "wgs84",
      success: function (t) {
        console.log(t);
        var e = t.latitude + "," + t.longitude;
        getApp().request({
          url: getApp().api.default.qq_map,
          data: {
            op: e
          },
          success: function (dw) {
            console.log(dw), n.setData({
              city: dw.data.result.address_component.city,
              dqwz: dw.data.result.address_component.district
            });
          }
        })
      }
    }), app.request({
      url: getApp().api.default.city_list,
      cachetime: "0",
      success: function (e) {
        n.setData({
          hotcityList: e.data.hot_list,
          cityList: e.data.list
        });
      }
    })
  },

  changecity: function (e) {
    var c = e.currentTarget.dataset.city;
    console.log(c), wx.setStorageSync("city", c), wx.setStorageSync("city_type", 1);

    var o = getCurrentPages(), a = (o[o.length - 1], o[o.length - 2]);
    a.setData({
      city: c
    }), a.loadData(), wx.navigateBack({
      url: "index"
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})